<div class="wrap cfix">
  <div class="main-cont innerWrap">
    <div id="content">
    	<div class="strap multimedia" style="margin: 10px 0px 0px 0px;border: none;padding: 10px 0px 0px 0px;">
			<header class="cf" style="margin-bottom:0px;">
			<h2>&nbsp;</h2>
			<ul class="nav">
				<li ><a href="<?php echo base_url(); ?>cau-hoi-moi-nhat.html">Câu hỏi mới nhất</a></li>
				<li ><a href="<?php echo base_url(); ?>cau-hoi-nhieu-tra-loi-nhat.html">Nhiều trả lời nhất</a></li>
				<li ><a href="<?php echo base_url(); ?>cau-hoi-hay-nhat.html">Câu hỏi hay nhất</a></li>
                <li ><a style="color:#f00;font-weight:bold;" href="<?php echo base_url(); ?>dang-nhap.html">Tài khoản</a></li>
			</ul>
			</header>
		</div>
        
      <section class="top-page">
        <section id="WeekendStrip">
          <div class="weekender-col-1">
            <article class="article feature hero-landscape"> <a href="<?php echo $links; ?>" title="<?php echo $category['names']; ?>"><img src="<?php echo base_url()."uploads/cate/".$category['images']; ?>" width="420" height="237" alt="<?php echo $category['names']; ?>" title="<?php echo $category['names']; ?>"></a>
              <div class="wof">
                <h3><a href="<?php echo $links; ?>" title="<?php echo $category['names']; ?>"><?php echo $category['names']; ?></a></h3>
                <p><?php echo $category['info']; ?></p>
              </div>
            </article>
          </div>
          <?php $j = 2; foreach($listcago as $cagorie){ ?>
          <div class="weekender-col-<?php echo $j; ?> <?php if($j == 4){ echo "last";}?>">
            <article class="liftout article feature <?php if($j == 2){ echo "image-only";}?>"><a href="<?php echo $category['rewrite']."/".$cagorie['rewrite']; ?>.html" title=""><img src="<?php echo base_url()."uploads/cate/thumb/".$cagorie['image']; ?>" alt=""></a>
              <div class="wof">
                <h3><a href="<?php echo $category['rewrite']."/".$cagorie['rewrite']; ?>.html" title=""><?php echo $cagorie['name']; ?></a></h3>
                <p><?php echo $cagorie['shortinfo']; ?></p>
              </div>
            </article>
          </div>
          <?php $j++; } ?>
          <div style="clear:left"></div>
        </section>
        <div class="col last" style="width:250px">
          <div id="adspot-300x250-pos-1" class="ad" style="width:250px"> <img src="<?php echo base_url();?>public/images/adsense-300x250.gif" width="250" alt="" /> </div>
        </div>
        <section id="Newswell">
          <div class="col strap personalised" style="width:160px;margin-right:17px">
            <section id="Timeout"> 
              <article class="article lifestyle clippingArea clippingAction"> <a href="#" title=""><img src="<?php echo base_url();?>public/images/th-495359715-140x93.jpg" width="140" height="93" alt=""></a>
                <div>
                  <h3><a href="#" title="">Too far? Rihanna bares (nearly) all on the red carpet</a></h3>
                  <div class="article-meta"> <em class="access">Contains:</em> <span class="icon poll" title="Article contains a poll">poll</span> <span class="icon gallery" title="Photo gallery">gallery</span> </div>
                </div>
              </article>
              <article class="article world clippingArea clippingAction"> <a href="#" title=""><img src="<?php echo base_url();?>public/images/th-sunbather-140x93.jpg" width="140" height="93" alt=""></a>
                <div>
                  <h3><a href="#" title="">Lucky escape: Plane narrowly misses beach sunbather</a></h3>
                  <div class="article-meta"> <em class="access">Contains:</em> <span class="icon video" title="This article contains a video.">This article contains a video.</span> </div>
                </div>
              </article>
              <article class="article entertainment clippingArea clippingAction"> <a href="#" title=""><img src="<?php echo base_url();?>public/images/Tyrion-thrones-th-140x93.jpg" width="140" height="93" alt=""></a>
                <div>
                  <h3><a href="#" title="">Game of Thrones shocker: how much can viewers stand?</a></h3>
                  <div class="article-meta"> <em class="access">Contains:</em> <a href="#"><span title="comments" class="icon comments">total comments</span>67</a> </div>
                </div>
              </article>
              <article class="article domain clippingArea clippingAction"> <a href="#" title=""><img src="<?php echo base_url();?>public/images/20110131943pio24144319--1-_320-140x93.jpg" width="140" height="93" alt=""></a>
                <div>
                  <h3><a href="#" title="">Swimming in it: Sydney mansion sells for $30 million</a></h3>
                  <div class="article-meta"> <em class="access">Contains:</em> <span class="icon gallery" title="Photo gallery">gallery</span> </div>
                </div>
               </article>
            </section>
          </div>
          <?php $this->load->library("string"); ?>
          <div class="col strap breaking-news" style="width:492px">
            <div class="homelink">&spades; <a href="<?php echo base_url(); ?>">Trang chủ</a> &raquo; <a href="<?php echo $category['rewrite']; ?>.html" title="<?php echo $category['names']; ?>"><?php echo $category['names']; ?></a> &raquo; <a href="<?php echo $links; ?>" title="<?php echo $result['title']; ?>"><?php echo $result['title']; ?></a></div>
            <div class="dquestion">
	        	<div class="quesuser">
	                <?php if($result['image'] == NULL){ ?>
	            	<img src="<?php echo base_url(); ?>public/images/no-avatar.png" width="90" height="90" alt="<?php echo $result['username'] ?>" title="<?php echo $result['username'] ?>" />
	                <?php }else{ ?>
	                <img src="<?php echo base_url(); ?>uploads/users/thumb/<?php echo $result['image']; ?>" width="90" height="90" alt="<?php echo $result['username'] ?>" title="<?php echo $result['username'] ?>" />
	                <?php } ?>
	            </div>
	            <div class="quesinfo">
	            	<h1><?php echo $result['title']; ?></h1>
	                <p class="qinfo">Gửi bởi <a href="#"><?php echo $result['username']; ?></a> lúc <?php echo $result['datetime']; ?></p>
	            	<div class="quesinfocon"><?php echo $result['info']; ?></div>
                    
					<!-- AddThis Button BEGIN -->
					<div class="addthis_toolbox addthis_default_style" style="margin-top: 10px;">
					<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
					<a class="addthis_button_tweet"></a>
					<a style="margin-left:-30px" class="addthis_button_google_plusone" g:plusone:size="medium"></a>
					<a style="margin-left:-30px" class="addthis_button_pinterest_pinit" pi:pinit:layout="horizontal" pi:pinit:url="http://www.addthis.com/features/pinterest" pi:pinit:media="http://www.addthis.com/cms-content/images/features/pinterest-lg.png"></a>
					<a style="margin-left:-10px" class="addthis_counter addthis_pill_style"></a>
					</div>
					<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-523824bb471c1b61"></script>
					<!-- AddThis Button END -->
					
	            </div>
	            <div class="cls"></div>
	        </div>
            <div class="totalansw">
	        	<h3>Có <?php if(isset($listanswer)){ echo count($listanswer);}else{ echo 0;} ?> câu trả lời</h3>
	        </div>
            <script type="text/javascript">
				$(document).ready(function(){
					$(document).on("click",".fdel",function(){
						$id = $(this).attr("title");
						$type = $(this).attr("name");
						if(confirm('Bạn có chắc không?')) {
		  					$(this).parent().parent().fadeOut();
		  					jQuery.post("<?php echo base_url()."home/answers/manaasw"; ?>",{id:$id,type:$type},function(result){
								if(result == "edit"){
									window.location = "<?php echo base_url()."sua-cau-tra-loi.html?quesid="; ?>"+$id+"&url=<?php echo $links; ?>";
								}
		  					});
						}else{ return false; }
					});
					$(document).on("click",".vtclick",function(){
						$val = $(this).text();
						$total = parseFloat($val) + 1;
						$aswid = $(this).attr("dataid");
						$type = $(this).attr("name");
						$(this).html($total);
						$(this).addClass("upactive");
						jQuery.post("<?php echo base_url()."home/answers/votenow"; ?>",{val:$val,type:$type,aswid:$aswid},function(result){
							if(result == 1){
								window.location = "<?php echo base_url(); ?>dang-nhap.html";
							}else{
								alert("true");
							}
						});
					});
				});
			</script>
            <div class="listanswer" id="listanswer">
	        	<?php if(isset($listanswer)){ ?>
	        	<?php foreach($listanswer as $answers){ ?>
	        	<div class="answers">
	            	<div class="lanswerl">
	                    <img src="<?php echo base_url(); ?>uploads/users/thumb/<?php echo $answers['image']; ?>" width="50" alt="<?php echo $answers['username']; ?>" title="<?php echo $answers['username']; ?>" />
	                    <p style="padding:3px 0px"><a href="#"><?php echo $answers['username']; ?></a></p>
		            </div>
		            <div class="lanswerr">
	                	<?php if(isset($this->session->userdata['userlevel']) && $this->session->userdata['userlevel'] == 1){ ?>
	                	<a href="javascript:void(0)" rel="nofollow" name="hide" class="fdel" title="<?php echo $answers['aid']; ?>">Ẩn</a>
	                	<a href="javascript:void(0)" rel="nofollow" name="del" class="fdel" title="<?php echo $answers['aid']; ?>">Xóa</a>
	                    <a href="javascript:void(0)" rel="nofollow" name="edit" class="fdel" title="<?php echo $answers['aid']; ?>">Sửa</a>
	                    <?php } ?>
		            	<div class="answercon">
		                	<?php echo $answers['ainfo']; ?>
		                </div>
		            	<div class="answertool">
	                    	<div class="ansup">
	                        	<a href="javascript:void(0)" name="voteup" dataid="<?php echo $answers['aid']; ?>" class="voteup vtclick"><?php echo $answers['alike']; ?></a>
	                        </div>
	                        <div class="ansdown">
	                        	<a href="javascript:void(0)" name="votedown" dataid="<?php echo $answers['aid']; ?>" class="votedown vtclick"><?php echo $answers['adislike']; ?></a>
	                        </div>
	                        <div class="ansnow">
	                            <a href="javascript:void(0)" class="commnow">Trả lời</a>
	                        </div>
		                </div>
		            </div>
		            <div class="cls"></div>
	            </div>
	        	<?php } } ?>
            	<script type="text/javascript">
				$(document).ready(function(){
					$("#fanswer").focus(function(){
						//$(this).css("height","140px");
					});
	                $("#fsubmit").click(function(){
						$userid = $("#fuserid").val();
						$fusername = $("#fusername").val();
						$quesid = $("#fquestid").val();
						$cateid = $("#fcateid").val();
						$value  = $("#fanswer").val();
						$errors = $("#ferrors");$result = $("#listanswer");
						if($userid == ""){
							window.location = "<?php echo base_url()."dang-nhap.html?url=".$links; ?>";
						}else{
							if($value == ""){
								$errors.text("Bạn chưa nhập câu trả lời").show();
							}else{
								if($value.length < 10){
									$errors.text("Câu trả lời quá ngắn!").show();
								}else{
									$errors.removeAttr("id").html("<img src='<?php echo base_url(); ?>public/images/4-0.gif' alt='' /> loading...");
									jQuery.post("<?php echo base_url()."home/question/asnwers"; ?>",{userid:$userid,fusername:$fusername,quesid:$quesid,cateid:$cateid,value:$value},function(result){
										$errors.html("").hide();
										$result.html(result);
										$("#fanswer").val("").css("height","57px");
									});
								}
							}
						}
						return false;
					});
	            });
	            </script>
                <div class="fanswer">
				<?php if(isset($this->session->userdata['userid'])){ ?>
                    <?php $this->load->view("layouts/form-answer-login"); ?>			        
                <?php }else{ ?>
                    <p id="ferrors" style="display:block">Bạn chưa <a href="<?php echo base_url()."dang-nhap.html?url=".$links; ?>" style="color:#060">đăng nhập</a>, bạn không thể trả lời câu hỏi này</p>
                    <form action="" method="post">
                    <div class="fanserl">
                        <img src="<?php echo base_url(); ?>public/images/no-avatar.png" width="50" />
                    </div>
                    <div class="fanserm">
                        <textarea name="answer" id="fanswer" cols="50" rows="4" placeholder="Đăng nhập để trả lời!" disabled="disabled"></textarea>
                    </div>
                    <div class="fanserr">
                        <input type="submit" name="submit" id="fsubmit" value="Trả lời" disabled="disabled" />
                    </div>
                    </form>
                <?php } ?>
                </div>
	        </div>
          </div>
        </section>
        <div class="col last strap" style="width:250px">
          <div class="ad" style="width:250px"> <img src="<?php echo base_url();?>public/images/adsense-300x250.gif" width="250" alt="" /> </div>
        </div>
        </div>
      </section>
      <section class="strap">
        <div id="adspot-728x90-pos-1" class="ad" style='display:none;'></div>
      </section>
    </div>
  </div>
</div>